@extends('layouts.fz')
@section('css')
    <link href="{{asset('assets/css/bootstrap.css')}}" rel="stylesheet" />
    <!-- FontAwesome Styles-->
    <link href="{{asset('assets/css/font-awesome.css')}}" rel="stylesheet" />
    <!-- Custom Styles-->
    <link href="{{asset('assets/css/custom-styles.css')}}" rel="stylesheet" />
    <!-- Google Fonts-->
    <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
    <link href="{{asset('assets/js/dataTables/dataTables.bootstrap.css')}}" rel="stylesheet" />
    <link href="{{asset('assets/css/daterangepicker-bs3.css')}}" rel="stylesheet" />

@endsection

@section('head')
    <h3 class="page-header">

    </h3>
    <ol class="breadcrumb">
        <li><a href="#">主页</a></li>
        <li><a href="#">审核管理</a></li>
        <li class="active">已审核列表</li>
    </ol>
@endsection
@section('contain')


    <div class="row">
        <div class="col-md-12">
            <!-- Advanced Tables -->
            <div class="panel panel-default">
                <div class="panel-heading">
                    已审核列表


                    <button type="submit" style="float: right" class="btn btn-primary" onclick="method('dataTables-example')"><i class="fa fa-cloud-download"></i> 导出数据</button>
                </div>
                <div class="panel-body">
                    <div class="">
                        <form class="form-horizontal">
                            <fieldset>
                                <div class="control-group">
                                    <div class="controls">
                                        <div class="input-prepend input-group" >
                                           <span class="add-on input-group-addon">
					                    <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
					                        </span>

                                            <input type="text" readonly="readonly" style="width: 200px" name="reservation" id="reservation" class="form-control"  />

                                        </div>
                                    </div>
                                </div>
                            </fieldset>
                        </form>

                        <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>名称</th>
                                <th>类型</th>
                                <th>价格</th>
                                <th>数量</th>
                                <th>领用部门</th>
                                <th>录入人名称</th>
                                <th>说明</th>
                                <th>处理状态</th>
                                <th>拒绝原因</th>
                                <th>录入时间</th>
                                <th>操作</th>
                                <th hidden="hidden">unix时间</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($order as $arr)
                                <tr class="odd gradeX">
                                    <td>{{$arr->id}}</td>
                                    <td>{{\App\Product::getName($arr->product_id)}}</td>
                                    <td>{{\App\Product::getType($arr->product_id)}}</td>
                                    <td>{{\App\Product::getPrice($arr->product_id)}}</td>
                                    <td>{{$arr->number}}</td>
                                    <td>{{\App\Department::getDepartmentById($arr->department)}}</td>
                                    <td>{{\App\User::getNameById($arr->user_id)}}</td>
                                    <td>{{$arr->explain}}</td>
                                    <td>{{\App\Order::getState($arr->state)}}</td>
                                    <td>{{$arr->rejected}}</td>
                                    <td>{{$arr->created_at}}</td>
                                    <td class="center">
                                        <button class="btn btn-primary" onclick="confirmBox('{{url('order_grant')}}/{{$arr->id}}')" {{$arr->state===2?'disabled="disabled"':''}}><i class="fa fa-edit"> </i>发放</button>

                                    </td>
                                    <td hidden="hidden">{{strtotime($arr->created_at)}}</td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>

                </div>
            </div>
            <!--End Advanced Tables -->
        </div>
    </div>
@endsection
@section('js')
    <script src="{{asset('assets/js/jquery-1.10.2.js')}}"></script>
    <!-- Bootstrap Js -->
    <script src="{{asset('assets/js/bootstrap.min.js')}}"></script>
    <!-- Metis Menu Js -->
    <script src="{{asset('assets/js/jquery.metisMenu.js')}}"></script>
    <!-- Custom Js -->
    <script src="{{asset('assets/js/moment.js')}}"></script>
    <script src="{{asset('assets/js/daterangepicker.js')}}"></script>
    <script src="{{asset('assets/js/dataTables/jquery.dataTables.js')}}"></script>
    <script src="{{asset('assets/js/dataTables/dataTables.bootstrap.js')}}"></script>

    <script>

        var timestart='';
        var timeend='';
        $.fn.dataTable.ext.search.push(
            function( settings, data, dataIndex ) {
                var min = parseInt( timestart, 10 );
                var max = parseInt( timeend, 10 );
                var time = parseFloat( data[12] ) || 0; // use data for the age column

                if ( ( isNaN( min ) && isNaN( max ) ) ||
                    ( isNaN( min ) && age <= max ) ||
                    ( min <= time   && isNaN( max ) ) ||
                    ( min <= time   && time <= max ) )
                {
                    return true;
                }
                return false;
            }
        );
        $(document).ready(function () {


            var table =  $('#dataTables-example').DataTable({
                "oLanguage": {
                    "sProcessing": "正在获取数据，请稍后...",
                    "sLengthMenu": "显示 _MENU_ 条",
                    "sZeroRecords": "没有您要搜索的内容",
                    "sInfo": "从 _START_ 到  _END_ 条记录 总记录数为 _TOTAL_ 条",
                    "sInfoEmpty": "记录数为0",
                    "sInfoFiltered": "(全部记录数 _MAX_ 条)",
                    "sInfoPostFix": "",
                    "sSearch": "搜索",
                    "sUrl": "",
                    "oPaginate": {
                        "sFirst": "第一页",
                        "sPrevious": "上一页",
                        "sNext": "下一页",
                        "sLast": "最后一页"
                    }
                },
                "aLengthMenu": [[10, 25, 50, 100,-1], [10, 25, 50, 100,"全部"]]
            });
            $('#reservation').daterangepicker(null, function(start, end, label) {
                var a=start.toISOString().replace(/T/, " ");
                var b=end.toISOString().replace(/T/, " ");
                timestart = Date.parse(new Date(a));
                timeend = Date.parse(new Date(b));
                timestart=timestart/1000;
                timeend=timeend/1000;
                table.draw();
            });
        });

        function confirmBox(url) {
            console.log(url);
            $('#confirmBoxOk').attr('href',url);
            $('#confirmBox').modal()
        }



    </script>
    <script src="{{asset('assets/js/custom-scripts.js')}}"></script>

@endsection